package com.inmobi.commons.internal;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileOperations
{
  public static boolean getBooleanPreferences(Context paramContext, String paramString1, String paramString2)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to get preferences..App context NULL");
      return false;
    }
    return paramContext.getSharedPreferences(paramString1, 0).getBoolean(paramString2, false);
  }

  public static int getIntPreferences(Context paramContext, String paramString1, String paramString2)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to get preferences..App context NULL");
      return 0;
    }
    return paramContext.getSharedPreferences(paramString1, 0).getInt(paramString2, 0);
  }

  public static long getLongPreferences(Context paramContext, String paramString1, String paramString2)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to get preferences..App context NULL");
      return 0L;
    }
    return paramContext.getSharedPreferences(paramString1, 0).getLong(paramString2, 0L);
  }

  public static String getPreferences(Context paramContext, String paramString1, String paramString2)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to get preferences..App context NULL");
      return null;
    }
    return paramContext.getSharedPreferences(paramString1, 0).getString(paramString2, null);
  }

  public static boolean isFileExist(Context paramContext, String paramString)
  {
    boolean bool1 = new File(paramContext.getDir("data", 0), paramString).exists();
    boolean bool2 = false;
    if (bool1)
      bool2 = true;
    return bool2;
  }

  public static String readFileAsString(Context paramContext, String paramString)
    throws IOException
  {
    File localFile = new File(paramContext.getCacheDir().getAbsolutePath() + File.separator + paramString);
    if (localFile.createNewFile());
    BufferedReader localBufferedReader = new BufferedReader(new FileReader(localFile));
    StringBuffer localStringBuffer = new StringBuffer();
    while (true)
    {
      String str = localBufferedReader.readLine();
      if (str == null)
        break;
      localStringBuffer.append("\n").append(str);
    }
    localBufferedReader.close();
    if (localStringBuffer.length() >= 1)
      return localStringBuffer.substring(1).toString();
    return "";
  }

  // ERROR //
  public static Object readFromFile(Context paramContext, String paramString)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_0
    //   3: ifnull +19 -> 22
    //   6: aload_1
    //   7: ifnull +15 -> 22
    //   10: ldc 12
    //   12: aload_1
    //   13: invokevirtual 18	java/lang/String:trim	()Ljava/lang/String;
    //   16: invokevirtual 22	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   19: ifeq +12 -> 31
    //   22: ldc 24
    //   24: ldc 155
    //   26: invokestatic 158	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;)V
    //   29: aload_2
    //   30: areturn
    //   31: new 66	java/io/File
    //   34: dup
    //   35: aload_0
    //   36: ldc 68
    //   38: iconst_0
    //   39: invokevirtual 72	android/content/Context:getDir	(Ljava/lang/String;I)Ljava/io/File;
    //   42: aload_1
    //   43: invokespecial 75	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   46: astore_3
    //   47: new 160	java/io/ObjectInputStream
    //   50: dup
    //   51: new 162	java/io/FileInputStream
    //   54: dup
    //   55: aload_3
    //   56: invokespecial 163	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   59: invokespecial 166	java/io/ObjectInputStream:<init>	(Ljava/io/InputStream;)V
    //   62: astore 4
    //   64: aload 4
    //   66: invokevirtual 170	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   69: astore 16
    //   71: aload 16
    //   73: astore_2
    //   74: aload 4
    //   76: astore 6
    //   78: aload 6
    //   80: ifnull -51 -> 29
    //   83: aload 6
    //   85: invokevirtual 171	java/io/ObjectInputStream:close	()V
    //   88: aload_2
    //   89: areturn
    //   90: astore 7
    //   92: ldc 24
    //   94: ldc 173
    //   96: invokestatic 158	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;)V
    //   99: iconst_0
    //   100: invokestatic 179	java/lang/Boolean:valueOf	(Z)Ljava/lang/Boolean;
    //   103: areturn
    //   104: astore 17
    //   106: aconst_null
    //   107: astore 4
    //   109: ldc 24
    //   111: ldc 181
    //   113: invokestatic 158	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;)V
    //   116: aload 4
    //   118: astore 6
    //   120: aconst_null
    //   121: astore_2
    //   122: goto -44 -> 78
    //   125: astore 9
    //   127: aconst_null
    //   128: astore 6
    //   130: ldc 24
    //   132: ldc 183
    //   134: aload 9
    //   136: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   139: aconst_null
    //   140: astore_2
    //   141: goto -63 -> 78
    //   144: astore 11
    //   146: aconst_null
    //   147: astore 6
    //   149: ldc 24
    //   151: ldc 188
    //   153: aload 11
    //   155: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   158: aconst_null
    //   159: astore_2
    //   160: goto -82 -> 78
    //   163: astore 13
    //   165: aconst_null
    //   166: astore 6
    //   168: ldc 24
    //   170: ldc 190
    //   172: aload 13
    //   174: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   177: aconst_null
    //   178: astore_2
    //   179: goto -101 -> 78
    //   182: astore 15
    //   184: aconst_null
    //   185: astore 6
    //   187: ldc 24
    //   189: ldc 192
    //   191: aload 15
    //   193: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   196: aconst_null
    //   197: astore_2
    //   198: goto -120 -> 78
    //   201: astore 14
    //   203: aload 4
    //   205: astore 6
    //   207: aload 14
    //   209: astore 15
    //   211: goto -24 -> 187
    //   214: astore 12
    //   216: aload 4
    //   218: astore 6
    //   220: aload 12
    //   222: astore 13
    //   224: goto -56 -> 168
    //   227: astore 10
    //   229: aload 4
    //   231: astore 6
    //   233: aload 10
    //   235: astore 11
    //   237: goto -88 -> 149
    //   240: astore 8
    //   242: aload 4
    //   244: astore 6
    //   246: aload 8
    //   248: astore 9
    //   250: goto -120 -> 130
    //   253: astore 5
    //   255: goto -146 -> 109
    //
    // Exception table:
    //   from	to	target	type
    //   83	88	90	java/io/IOException
    //   47	64	104	java/io/EOFException
    //   47	64	125	java/io/FileNotFoundException
    //   47	64	144	java/io/StreamCorruptedException
    //   47	64	163	java/io/IOException
    //   47	64	182	java/lang/ClassNotFoundException
    //   64	71	201	java/lang/ClassNotFoundException
    //   64	71	214	java/io/IOException
    //   64	71	227	java/io/StreamCorruptedException
    //   64	71	240	java/io/FileNotFoundException
    //   64	71	253	java/io/EOFException
  }

  // ERROR //
  public static boolean saveToFile(Context paramContext, String paramString, Object paramObject)
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnull +23 -> 24
    //   4: aload_1
    //   5: ifnull +19 -> 24
    //   8: ldc 12
    //   10: aload_1
    //   11: invokevirtual 18	java/lang/String:trim	()Ljava/lang/String;
    //   14: invokevirtual 22	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   17: ifne +7 -> 24
    //   20: aload_2
    //   21: ifnonnull +12 -> 33
    //   24: ldc 24
    //   26: ldc 196
    //   28: invokestatic 158	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;)V
    //   31: iconst_0
    //   32: ireturn
    //   33: new 66	java/io/File
    //   36: dup
    //   37: aload_0
    //   38: ldc 68
    //   40: iconst_0
    //   41: invokevirtual 72	android/content/Context:getDir	(Ljava/lang/String;I)Ljava/io/File;
    //   44: aload_1
    //   45: invokespecial 75	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   48: astore_3
    //   49: new 198	java/io/ObjectOutputStream
    //   52: dup
    //   53: new 200	java/io/FileOutputStream
    //   56: dup
    //   57: aload_3
    //   58: iconst_0
    //   59: invokespecial 203	java/io/FileOutputStream:<init>	(Ljava/io/File;Z)V
    //   62: invokespecial 206	java/io/ObjectOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   65: astore 4
    //   67: aload 4
    //   69: aload_2
    //   70: invokevirtual 210	java/io/ObjectOutputStream:writeObject	(Ljava/lang/Object;)V
    //   73: aload 4
    //   75: invokevirtual 213	java/io/ObjectOutputStream:flush	()V
    //   78: aload 4
    //   80: ifnull +8 -> 88
    //   83: aload 4
    //   85: invokevirtual 214	java/io/ObjectOutputStream:close	()V
    //   88: iconst_1
    //   89: ireturn
    //   90: astore 6
    //   92: ldc 24
    //   94: ldc 216
    //   96: aload 6
    //   98: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   101: iconst_0
    //   102: ireturn
    //   103: astore 5
    //   105: ldc 24
    //   107: ldc 218
    //   109: aload 5
    //   111: invokestatic 186	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   114: iconst_0
    //   115: ireturn
    //   116: astore 7
    //   118: ldc 24
    //   120: ldc 173
    //   122: invokestatic 158	com/inmobi/commons/internal/Log:internal	(Ljava/lang/String;Ljava/lang/String;)V
    //   125: iconst_0
    //   126: ireturn
    //
    // Exception table:
    //   from	to	target	type
    //   49	78	90	java/io/FileNotFoundException
    //   49	78	103	java/io/IOException
    //   83	88	116	java/io/IOException
  }

  public static void setPreferences(Context paramContext, String paramString1, String paramString2, float paramFloat)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to set preferences..App context NULL");
      return;
    }
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(paramString1, 0).edit();
    localEditor.putFloat(paramString2, paramFloat);
    localEditor.commit();
  }

  public static void setPreferences(Context paramContext, String paramString1, String paramString2, int paramInt)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to set preferences..App context NULL");
      return;
    }
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(paramString1, 0).edit();
    localEditor.putInt(paramString2, paramInt);
    localEditor.commit();
  }

  public static void setPreferences(Context paramContext, String paramString1, String paramString2, long paramLong)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to set preferences..App context NULL");
      return;
    }
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(paramString1, 0).edit();
    localEditor.putLong(paramString2, paramLong);
    localEditor.commit();
  }

  public static void setPreferences(Context paramContext, String paramString1, String paramString2, boolean paramBoolean)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.debug("IMCOMMONS_3.7.0", "Failed to set preferences..App context NULL");
      return;
    }
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(paramString1, 0).edit();
    localEditor.putBoolean(paramString2, paramBoolean);
    localEditor.commit();
  }

  public static boolean setPreferences(Context paramContext, String paramString1, String paramString2, String paramString3)
  {
    if ((paramContext == null) || (paramString1 == null) || (paramString2 == null) || ("".equals(paramString1.trim())) || ("".equals(paramString2.trim())))
    {
      Log.internal("IMCOMMONS_3.7.0", "Failed to set preferences..App context NULL");
      return false;
    }
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences(paramString1, 0).edit();
    localEditor.putString(paramString2, paramString3);
    localEditor.commit();
    return true;
  }

  public static void writeStringToFile(Context paramContext, String paramString1, String paramString2, boolean paramBoolean)
    throws IOException
  {
    File localFile = new File(paramContext.getCacheDir().getAbsolutePath() + File.separator + paramString1);
    if (localFile.createNewFile());
    BufferedWriter localBufferedWriter = new BufferedWriter(new FileWriter(localFile, paramBoolean));
    localBufferedWriter.write(paramString2);
    localBufferedWriter.close();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.commons.internal.FileOperations
 * JD-Core Version:    0.6.2
 */